package cn.gson.boot.model.service;

import cn.gson.boot.model.dao.AttributeDao;
import cn.gson.boot.model.dao.AttributeValueDao;
import cn.gson.boot.model.dao.SupplierContactDao;
import cn.gson.boot.model.mapper.AttributeMapper;
import cn.gson.boot.model.mapper.SupplierContactMapper;
import cn.gson.boot.model.mapper.SupplierMapper;
import cn.gson.boot.model.pojos.Attribute;
import cn.gson.boot.model.pojos.AttributeValue;
import cn.gson.boot.model.pojos.ChanpincongbiaoShuxinzhi;
import cn.gson.boot.model.pojos.SupplierContact;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SupplierContactService {
    @Autowired
    SupplierContactMapper supplierContactMapper;
    @Autowired
    SupplierContactDao supplierContactDao;

    //供应商联系人分页查询
    public List<SupplierContact> selectSupplierContact(String search, String type) {
        return supplierContactMapper.selectSupplierContact(search,type);
    }

    //新增联系人
    public void addSupplierContact(SupplierContact supplierContact) {
        supplierContact.setSupcontactSc(0);
        supplierContactDao.save(supplierContact);
    }

    //查询某个供应商下有哪些联系人
    public List<SupplierContact> ContactsBySupId(String supplierName) {
        return supplierContactMapper.ContactsBySupId(supplierName);
    }

    //查询需要修改的供应商联系人
    public List<SupplierContact> upSupContact(Integer supcontactId) {
        return supplierContactMapper.upSupContact(supcontactId);
    }

    //删除供应商联系人
    public void delSupContact(Integer supcontactId) {
        SupplierContact sup = supplierContactDao.findById(supcontactId).get();
        sup.setSupcontactSc(1);
        supplierContactDao.save(sup);
    }

}
